<?php

namespace app\myr\controller;
use app\wechat\service\JwtService;
use Decimal\Decimal;
use think\admin\Controller;
use think\Request;
use think\Db;
use think\Validate;
use app\myr\model\Userintegral as UserintegralModel;
use think\admin\helper\QueryHelper;
use app\myr\model\Winrecord;

/**
 * 消费者积分管理
 */
class Userintegral extends Controller
{
     
    /**
     * 列表
     * @auth true  # 表示需要验证权限
     * @menu true  # 添加系统菜单节点
     * @login true # 强制登录才可访问
     */
    public function index(){
       UserintegralModel::mQuery()->layTable(function () {
            $this->title = '消费者积分管理';
        }, static function (QueryHelper $query) {
            $query->like("user_id,trace_code")->dateBetween('create_time');;
        });
    }
    
    protected function _index_page_filter(&$data)
    {
        foreach ($data as &$vo) {
            $win=Winrecord::where("sncode",$vo["trace_code"])->find();
            if($win["lottery_id"] == 44){
                $vo["price"]="加119元再来一罐";
            }else{
                $vo["price"]=$win["integral"]."元";
            }
            
            if($vo["is_newke"] == "1"){ $vo["is_newke"]="是";}
            else if($vo["is_newke"] == "0"){ $vo["is_newke"]="否"; }
            
            if($vo["status"] == "1"){ $vo["status"]="生效";}
            else if($vo["status"] == "2"){ $vo["status"]="回收"; }
        }
    }
    
}